package com.yonyou.cyxdms.sysmanage.client.config;

import com.yonyou.cyxdms.framework.interceptor.DMSFrameworkInterceptor;
import com.yonyou.cyxdms.sysmanage.client.interceptor.DMSSysManageInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @Author:zhangxianchao
 * @Description: //定义Web 相关
 * @Date:Created in 10:25 2018/7/18 0018
 * @Modified By:
 */
@Configuration
public class WebSysManageConfig extends WebMvcConfigurerAdapter {

    /**
     * 实现拦截器
     *
     * @param
     * @return org.springframework.web.servlet.HandlerInterceptor
     * @author zhangxianchao
     * @since 2018/11/16 0016
     */
    @Bean
    public HandlerInterceptor getSysManageRestInterceptor(){
        return new DMSSysManageInterceptor();
    }

    /**
     * 增加用户拦截
     *
     * @param registry
     * @return void
     * @author zhangxianchao
     * @since 2018/7/29 0029
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
         registry.addInterceptor(getSysManageRestInterceptor()).addPathPatterns("/**");
         super.addInterceptors(registry);
    }

}
